package microservicedemo.userclient.controller;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import microservicedemo.userclient.Client.UserServiceClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import microservicedemo.userclient.model.User;

@AllArgsConstructor
@RestController
@Slf4j
public class UserServiceClientController {

    @Autowired
    private final UserServiceClient userServiceClient;

    @PostMapping("/login")
    public String login(@RequestBody User user) {
        String exist = userServiceClient.login(user);
        log.info("-------------OK   /login--------------------");
        return exist;
    }

    @PostMapping("/register")
    public boolean register(@RequestBody User user) {
        userServiceClient.register(user);
        return true;
    }
}
